// 课程数据 - 根据courses表结构构造
console.log("✅  The current loading is the latest version of coursesData. js");
const coursesData = [
{
id: 1,
title: 'A Comprehensive Introduction to Linear Algebra',
description: 'A deep understanding of the core concepts of linear algebra, from matrix operations to vector spaces, lays a solid foundation for mathematics and engineering.',
courseIntro: 'This course systematically explains the basic theory of linear algebra, including matrices, determinants, vector spaces, linear transformations, etc. Through rich examples and exercises, help students master the problem-solving skills of linear algebra, and provide necessary mathematical tools for subsequent mathematics and engineering courses.',
teacher_id: 1,
category_id: 1, // Science and Engineering
cover_image: '../Homepage/images/courses/linear_algebra.png',
status: 'published',
enableNotes: 'open',
enableComments: 'open',
created_at: '2025-01-15T09:00:00.000Z',
updated_at: '2025-01-20T14:30:00.000Z',
category: 'Science and Engineering',
teacher: 'Professor Li Hua',
registerCount: 1200,
likes: 180,
recommend: true,
carouselImages: ['../Homepage/images/courses/linear_algebra.png'],
teachingPlan: 'Chapter 1: Matrix Operations \ Chapter 2: Determinants \ Chapter 3: Vector Space',
    catalog: 'Chapter 1 Matrix Operations \ Chapter 2 Determinants \ Chapter 3 Vector Space',
    assessmentStandard: '30% for regular homework and 70% for final exams',
    teacherEmail: 'lihua@university.edu'
},
{
id: 2,
title: 'Fundamentals of Advanced Mathematics',
description: 'From limits to integrals, comprehensively grasp the core concepts and problem-solving skills of advanced mathematics.',
courseIntro: 'This course provides a detailed explanation of the basic concepts of advanced mathematics, including limits, derivatives, integrals, series, and more. Through a large number of examples and exercises, help students establish a solid mathematical foundation and provide support for subsequent science and engineering courses.',
teacher_id: 2,
category_id: 1, // Science and Engineering
cover_image: '../Homepage/images/courses/calculus.png',
status: 'published',
enableNotes: 'open',
enableComments: 'open',
created_at: '2025-01-16T09:00:00.000Z',
updated_at: '2025-01-21T14:30:00.000Z',
category: 'Science and Engineering',
teacher: 'Professor Wang Qiang',
registerCount: 1350,
likes: 210,
recommend: true,
carouselImages: ['../Homepage/images/courses/calculus.png'],
teachingPlan: 'Chapter 1: Limits and Continuity Chapter 2: Derivatives and Differentiation',
    catalog: 'Chapter 1 Limits and Continuity \ Chapter 2 Derivatives and Differentiation \ Chapter 3 Integration',
    assessmentStandard: 'Unit test (40%)+final exam (60%)',
    teacherEmail: 'wangqiang@university.edu'
},
{
id: 3,
title: 'Introduction to College Physics',
description: 'Explore the mysteries of the physical world, from mechanics, thermodynamics to electromagnetics, and comprehensively master the core knowledge of university physics.',
courseIntro: 'This course systematically explains the basic content of college physics, including mechanics, thermodynamics, electromagnetics, optics, etc. By combining experiments and theories, we aim to help students gain a deeper understanding of physical phenomena and principles, and cultivate scientific thinking and experimental skills.',
teacher_id: 3,
category_id: 1, // Science and Engineering
cover_image: '../Homepage/images/courses/physics.png',
status: 'published',
enableNotes: 'open',
enableComments: 'open',
created_at: '2025-01-17T09:00:00.000Z',
updated_at: '2025-01-22T14:30:00.000Z',
category: 'Science and Engineering',
teacher: 'Professor Zhao Min',
registerCount: 1400,
likes: 220,
recommend: true,
carouselImages: ['../Homepage/images/courses/physics.png'],
teachingPlan: 'Chapter 1: Fundamentals of Mechanics \ Chapter 2: Fundamentals of Thermodynamics \ Chapter 3: Introduction to Electromagnetics',
catalog: 'Chapter 1 Mechanics \ Chapter 2 Thermodynamics \ Chapter 3 Electromagnetics',
assessmentStandard: 'Experimental report (30%)+final exam (70%)',
teacherEmail: 'zhaomin@university.edu'
},
{
id: 4,
title: 'Fundamentals of College English',
description: 'Enhance English listening, speaking, reading, and writing skills, laying a solid foundation for international communication and academic research.',
courseIntro: 'This course is designed specifically for college students, covering basic English grammar, vocabulary, listening, speaking, reading, and writing. By providing rich learning materials and interactive exercises, we aim to help students comprehensively improve their English proficiency and provide support for their future academic and career development.',
teacher_id: 4,
category_id: 3, // Education and Language
cover_image: '../Homepage/images/courses/english.png',
status: 'published',
enableNotes: 'open',
enableComments: 'open',
created_at: '2025-01-18T09:00:00.000Z',
updated_at: '2025-01-23T14:30:00.000Z',
category: 'Education and Language',
teacher: 'Professor Zhou Jie',
registerCount: 1600,
likes: 250,
recommend: true,
carouselImages: ['../Homepage/images/courses/english.png'],
teachingPlan: 'Chapter 1: Listening and Speaking Training \ Chapter 2: Reading Skills \ Chapter 3: Advanced Writing',
catalog: 'Chapter 1 Basic Grammar \ Chapter 2 Practical Spoken English \ Chapter 3 Academic Writing',
assessmentStandard: 'Oral test (20%)+written test (80%)',
teacherEmail: 'zhoujie@university.edu'
},
{
id: 5,
title: 'Technological Archaeology and Appreciation of Cultural Relics',
description: 'Explore ancient civilizations, combine modern technological means, and learn about cultural relic identification and protection.',
courseIntro: 'This course combines archaeology and modern technology to explain the excavation, identification, protection, and research methods of cultural relics. Through practical case analysis, help students understand ancient civilization, master the basic skills of cultural relic appreciation, and cultivate awareness of cultural heritage protection.',
teacher_id: 5,
category_id: 1, // Science and Engineering
cover_image: '../Homepage/images/courses/archaeology.png',
status: 'published',
enableNotes: 'open',
enableComments: 'open',
created_at: '2025-01-19T09:00:00.000Z',
updated_at: '2025-01-24T14:30:00.000Z',
category: 'Science and Engineering',
teacher: 'Professor Wu Yue',
registerCount: 1100,
likes: 170,
recommend: true,
carouselImages: ['../Homepage/images/courses/archaeology.png'],
teachingPlan: 'Chapter 1: Fundamentals of Archaeology \ Chapter 2: Techniques for Cultural Relic Appraisal \ Chapter 3: Protection of Cultural Heritage',
catalog: 'Chapter 1 Archaeological Methodology \ Chapter 2 Material Analysis of Cultural Relics \ Chapter 3 Restoration Technology Practice',
assessmentStandard: 'Field investigation (40%)+final thesis (60%)',
teacherEmail: 'wuyue@university.edu'
},
{
id: 6,
title: 'Fundamentals of Discrete Mathematics',
description: 'Mastering the core concepts of discrete mathematics lays a solid foundation for computer science and mathematical research.',
courseIntro: 'This course provides a detailed explanation of the basic concepts of discrete mathematics, including set theory, graph theory, logic, combinatorics, and more. Through rich examples and exercises, help students master the problem-solving skills of discrete mathematics and provide necessary mathematical tools for subsequent computer science courses.',
teacher_id: 6,
category_id: 1, // Science and Engineering
cover_image: '../Homepage/images/courses/discrete_math.png',
status: 'published',
enableNotes: 'open',
enableComments: 'open',
created_at: '2025-01-20T09:00:00.000Z',
updated_at: '2025-01-25T14:30:00.000Z',
category: 'Science and Engineering',
teacher: 'Professor Chen Tao',
registerCount: 1250,
likes: 190,
recommend: true,
carouselImages: ['../Homepage/images/courses/discrete_math.png'],
teachingPlan: 'Chapter 1: Sets and Logic \ Chapter 2: Fundamentals of Graph Theory \ Chapter 3: Combinatorial Mathematics',
catalog: 'Chapter 1 Mathematical Logic \ Chapter 2 Graph Theory \ Chapter 3 Recursive Relationships',
assessmentStandard: 'Project assignment (50%)+final exam (50%)',
teacherEmail: 'chentao@university.edu'
},
{
id: 7,
title: 'Introduction to Positive Psychology',
description: 'Explore the core concepts of positive psychology and learn how to cultivate a positive mindset and a happy life.',
courseIntro: 'This course systematically explains the basic theories of positive psychology, including happiness, strengths, positive emotions, meaning, and achievement. Through rich examples and interactive exercises, help students cultivate a positive attitude and enhance their sense of happiness in life.',
teacher_id: 7,
category_id: 5, // Education and Language
cover_image: '../Homepage/images/courses/positive_psychology.png',
status: 'published',
enableNotes: 'open',
enableComments: 'open',
created_at: '2025-01-21T09:00:00.000Z',
updated_at: '2025-01-26T14:30:00.000Z',
category: 'Education and Language',
teacher: 'Professor Liu Yang',
registerCount: 1300,
likes: 200,
recommend: true,
carouselImages: ['../Homepage/images/courses/positive_psychology.png'],
teachingPlan: 'Chapter 1: Psychology of Happiness \ Chapter 2: Cultivating Positive Emotions \ Chapter 3: Achievement Motivation Theory',
catalog: 'Chapter 1 Positive Self \ Chapter 2 Positive Relationships \ Chapter 3 Positive Coping',
assessmentStandard: 'Classroom participation (20%)+project presentation (80%)',
teacherEmail: 'liuyang@university.edu'
},
{
id: 8,
title: 'Music and Health',
description: 'Explore the impact of music on physical and mental health, and learn how to improve quality of life through music.',
courseIntro: 'This course combines musicology and psychology to explain the impact of music on emotions, stress, sleep, and other aspects. Through practical cases and interactive exercises, help students master the basic techniques of music therapy and improve their physical and mental health.',
teacher_id: 8,
category_id: 4, // Literature and Art
cover_image: '../Homepage/images/courses/music_health.png',
status: 'published',
enableNotes: 'open',
enableComments: 'open',
created_at: '2025-01-22T09:00:00.000Z',
updated_at: '2025-01-27T14:30:00.000Z',
category: 'Literature and Art',
teacher: 'Professor Sun Li',
registerCount: 1050,
likes: 160,
recommend: true,
carouselImages: ['../Homepage/images/courses/music_health.png'],
teachingPlan: 'Chapter 1: Fundamentals of Music Psychology \ Chapter 2: Music Therapy Techniques \ Chapter 3: Health Management Applications',
catalog: 'Chapter 1 Music and the Brain \ Chapter 2 Music Therapy Practice \ Chapter 3 Health Intervention Plan',
assessmentStandard: 'Practical cases (40%)+final thesis (60%)',
teacherEmail: 'sunli@university.edu'
},
{
id: 9,
title: 'Java Fundamentals',
description: 'From basic syntax to object-oriented programming, comprehensively master the core concepts and practical skills of Java programming.',
courseIntro: 'This course provides a detailed explanation of the fundamentals of Java programming, including variables, data types, control structures, classes, and objects. Through rich examples and project exercises, help students master the basic skills of Java programming and lay a solid foundation for subsequent software development.',
teacher_id: 9,
category_id: 2, // computer
cover_image: '../Homepage/images/courses/java.png',
status: 'published',
enableNotes: 'open',
enableComments: 'open',
created_at: '2025-01-23T09:00:00.000Z',
updated_at: '2025-01-28T14:30:00.000Z',
category: 'computer',
teacher: 'Professor Li Ming',
registerCount: 1450,
likes: 230,
recommend: true,
carouselImages: ['../Homepage/images/courses/java.png'],
teachingPlan: 'Chapter 1: Grammar Fundamentals \ Chapter 2: Object Oriented \ Chapter 3: Advanced Features',
catalog: 'Chapter 1 Data Types \ Chapter 2 Classes and Objects \ Chapter 3 Multithreaded Programming',
assessmentStandard: 'Experimental code (30%)+project defense (70%)',
teacherEmail: 'liming@university.edu'
},
{
id: 10,
title: 'Fundamentals of C++',
description: 'From basic syntax to advanced features, comprehensively master the core concepts and practical skills of C++programming.',
courseIntro: 'This course provides a detailed explanation of the basics of C++programming, including variables, data types, control structures, classes and objects, templates, and more. Through rich examples and project exercises, help students master the basic skills of C++programming and lay a solid foundation for subsequent software development.',
teacher_id: 10,
category_id: 2, // computer
cover_image: '../Homepage/images/courses/cpp.png',
status: 'published',
enableNotes: 'open',
enableComments: 'open',
created_at: '2025-01-24T09:00:00.000Z',
updated_at: '2025-01-29T14:30:00.000Z',
category: 'computer',
teacher: 'Professor Zhang Wei',
registerCount: 1500,
likes: 240,
recommend: true,
carouselImages: ['../Homepage/images/courses/cpp.png'],
teachingPlan: 'Chapter 1: Grammar and Memory \ Chapter 2: STL Container \ Chapter 3: System Programming',
catalog: 'Chapter 1 Input/Output \ Chapter 2 Classes and Inheritance \ Chapter 3 File Operations',
assessmentStandard: 'Code specifications (20%)+final project (80%)',
teacherEmail: 'zhangwei@university.edu'
}
];
// 分类数据
const categoriesData = [
    { id: 1, name: 'Science and Engineering', description: 'Basic disciplines such as mathematics, physics, chemistry, engineering, etc' },
    { id: 2, name: 'computer', description: 'Computer related courses such as programming, software development, and artificial intelligence' },
    { id: 3, name: 'Education and Language', description: 'Foreign language learning, educational theory, language and literature, etc' },
    { id: 4, name: 'Literature and Art', description: 'Literature, art, design, creation and other humanities and arts categories' },
    { id: 5, name: 'Entrepreneurship and Workplace', description: 'Entrepreneurship guidance, vocational skills, business management, etc' },
    { id: 6, name: 'Philosophy, History, and Culture', description: 'Philosophy, history, cultural studies, etc' },
    { id: 7, name: 'Economy and Management', description: 'Business courses such as economics, management, finance, etc' },
    { id: 8, name: 'medicine', description: 'Medical fundamentals, clinical medicine, pharmacy and other medical related fields' }
];
const teachersData = [
    { id: 1, name: 'Professor Li Hua', avatar: '../header-footer/images/ico.jpg', department: 'School of mathematics and statistics' },
    { id: 2, name: 'Professor Wang Qiang', avatar: '../header-footer/images/ico.jpg', department: 'School of mathematics and statistics' },
    { id: 3, name: 'Professor Zhao Min', avatar: '../header-footer/images/ico.jpg', department: 'School of physics' },
    { id: 4, name: 'Professor Zhou Jie', avatar: '../header-footer/images/ico.jpg', department: 'School of Foreign Languages' },
    { id: 5, name: 'Professor Wu Yue', avatar: '../header-footer/images/ico.jpg', department: 'Department of Archaeology' },
    { id: 6, name: 'Professor Chen Tao', avatar: '../header-footer/images/ico.jpg', department: 'School of mathematics and statistics' },
    { id: 7, name: 'Professor Liu Yang', avatar: '../header-footer/images/ico.jpg', department: 'department of psychology' },
    { id: 8, name: 'Professor Sun Li', avatar: '../header-footer/images/ico.jpg', department: 'college of art' },
    { id: 9, name: 'Professor Li Ming', avatar: '../header-footer/images/ico.jpg', department: 'School of computer science and technology' },
    { id: 10, name: 'Professor Zhang Wei', avatar: '../header-footer/images/ico.jpg', department: 'School of computer science and technology' }
];



// 初始化数据到IndexedDB的函数
async function initCoursesData() {
    if (!db) {
        console.error('Database not initialized');
        return;
    }

    try {
        // 清空现有数据（可选）
        const transaction = db.transaction(['courses'], 'readwrite');
        const store = transaction.objectStore('courses');
        
        // 检查是否已有数据
        const countRequest = store.count();
        console.log(coursesData)
        countRequest.onsuccess = function() {
            if (countRequest.result === 0) {
                // 如果没有数据，则添加课程数据
                coursesData.forEach(course => {
                    store.add(course);
                });
                console.log('Course data initialization completed');
            } else {
                console.log('Course data already exists, skip initialization');
            }
        };
    } catch (error) {
        console.error('Failed to initialize course data:', error);
    }
}


// 导出数据
window.coursesData = coursesData;
window.categoriesData = categoriesData;
window.teachersData = teachersData;
window.initCoursesData = initCoursesData;

// window.commentsData = commentsData;


